package _240310;

import java.util.*;

public class Test240310 {

    private static int N;
    private static char[][] photo;
    private static int[] dx = {0,0,1,-1};
    private static int[] dy = {1,-1,0,0};

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();
        scanner.nextLine();
        photo = new char[N][N];

        for(int i=0; i<N; i++) {
            String line = scanner.nextLine();
            photo[i] = line.toCharArray();
        }
        count();
        System.out.println(count());

    }
    // 计算岛屿(连通分量)数
    private static int count() {
        int res = 0;
        boolean[][] marked = new boolean[N][N];
        for (int i=0; i<N; i++) {
            for(int j=0; j<N; j++) {
                if (marked[i][j]==false && photo[i][j]=='#') {
                    dfs(i,j,marked);
                    res++;
                }
            }
        }
        return res;
    }

    private static void dfs(int x, int y, boolean[][] marked) {
        marked[x][y] = true; // 标记已访问
        // 对该节点的四个方向进行遍历--超界(不存在)、已访问(是陆地)、是海
        for (int i=0; i<4; i++) {
            int nextx = x + dx[i];
            int nexty = y + dy[i];
            if (marked[nextx][nexty] == true) {
                continue;
            }else if(photo[nextx][nexty] == '.') {
                photo[x][y] = '.'; // 淹没
                continue;
            }
            dfs(nextx, nexty, marked);
        }
    }

}
